#include <nice2d/piece/piecevisitor.h>

void PieceVisitor::visitPiece(std::shared_ptr<Piece> piece)
{
    if(piece)
        pieces.push_back(piece);
}

std::vector<std::shared_ptr<Piece> > PieceVisitor::getPieces() const{
    return pieces;
}

SpecifiedColorPieceVisitor::SpecifiedColorPieceVisitor(const sf::Color &newColor):
    color(newColor)
{
}

void SpecifiedColorPieceVisitor::visitPiece(std::shared_ptr<Piece> piece)
{
    if(piece && piece->getSpriteColor() == color)
        pieces.push_back(piece);
}

SpecifiedColorPieceNotDoneVisitor::SpecifiedColorPieceNotDoneVisitor(const sf::Color &newColor):
    color(newColor)
{
}

void SpecifiedColorPieceNotDoneVisitor::visitPiece(std::shared_ptr<Piece> piece)
{
    if(piece && piece->getSpriteColor() == color)
    {
        auto done = GET_COMPONENT(piece,Done);
        if(!done->isDone())
            pieces.push_back(piece);
    }
}